﻿/**
 * Input
 * 
 * @version 2012.01.18
 * @author  Bruno Miguel de Oliveira Tamer <bmotamer@gmail.com>
 */

#region C# Libraries

using System.Collections.Generic;

#endregion

#region XNA Libraries

using Microsoft.Xna.Framework.Input;

#endregion

namespace main.sdk.input
{

    public static class Input
    {
        private static readonly byte[] State = new byte[256];
        private static KeyboardState _OldState = Keyboard.GetState();
        private static KeyboardState _State    = Keyboard.GetState();

        public static void Update()
        {
            _OldState = _State;
            _State = Keyboard.GetState();
            Gamepad.Update();
        }

        public static bool Untouched(Keys key) { return (_State.IsKeyUp(key)   && _OldState.IsKeyUp(key)); }
        public static bool Trigger(Keys key)   { return (_State.IsKeyDown(key) && _OldState.IsKeyUp(key)); }
        public static bool Press(Keys key)     { return (_State.IsKeyDown(key)); }
        public static bool Release(Keys key)   { return (_State.IsKeyUp(key)   && _OldState.IsKeyDown(key)); }

        public static bool Down(Keys key)
        {
            return (_State.IsKeyDown(key));
        }

        public static bool AnyDown()
        {
            return (_State.GetPressedKeys().Length > 0);
        }

    }

}